import { useDict } from '@/utils/dict/useDict'
let course_type = useDict('course_type')
let course_status = useDict('course_status')
export const searchList = [
  {
    type: 'input',
    name: '课程名称',
    field: 'courseName',
  },
  {
    type: 'select',
    name: '课程状态',
    field: 'courseStatus',
    selectList: course_status
  },
  {
    type: 'select',
    name: '课程类型',
    field: 'courseTypeId',
    selectList: course_type
  }
]

export const listColumns = [
  {
    title: '课程名称',
    key: 'courseName',
  },
  {
    title: '所属专业群',
    key: 'majorGroup',
  },
  {
    title: '课程类型',
    key: 'courseTypeName',
  },
  {
    title: '课程状态',
    key: 'courseStatusName',
  },
  {
    title: '开课时间',
    key: 'startDate',
  },
  {
    title: '结课时间',
    key: 'endDate',
  },
]

export const actionArr = [
  {
    action: 'look',
    value: '查看',
  },
  {
    action: 'edit',
    value: '编辑',
  },
  {
    action: 'process',
    value: '办理',
    hiddenList: [
			{
				fileId: 'courseStatus',
				showTerm: ['47','48'],
			},
		]
  },
  {
    action: 'del',
    value: '删除',
  }
]
export const btnList = [
  {
    action: 'add',
    value: '新增',
    auth: ''
  }
];

export const rules = {
  courseName: [
    { required: true, message: '请输入课程名称', trigger: 'change' },
  ],
  courseTypeId: [
    { required: true, message: '请输入课程类型', trigger: 'change' },
  ],
  majorGroup: [
    { required: true, message: '请输入所属专业群', trigger: 'change' },
  ],
  courseHour: [
    { required: true, message: '请输入课时', trigger: 'change' },
  ],
  creditHourDistribute: [
    { required: true, message: '请输入学分分布', trigger: 'change' },
  ],
  emphasesContent: [
    { required: true, message: '请输入重点内容', trigger: 'change' },
  ],
  teachWeek: [
    { required: true, message: '请输入教学周次', trigger: 'change' },
  ],
  courseStatus: [
    { required: true, message: '请输入课程状态', trigger: 'change' },
  ],
  academicYear: [
    { required: true, message: '请输入学年学期', trigger: 'change' },
  ],
  checkType: [
    { required: true, message: '请输入考核方式', trigger: 'change' },
  ],
  startDate: [
    { required: true, message: '请输入开课时间', trigger: 'change' },
  ],
  endDate: [
    { required: true, message: '请输入结课时间', trigger: 'change' },
  ],
}
export const validateNotPureNumber = (rule, value, callback) => {
  // 如果值为空，根据需求决定是否校验通过
  if (!value) {
    return callback(); // 不校验空值，可根据实际需求修改
  }
  
  // 正则表达式：匹配纯数字（包括整数和小数）
  const pureNumberRegex = /^[+-]?(\d+(\.\d*)?|\.\d+)$/;
  
  if (pureNumberRegex.test(value)) {
    callback(new Error('不能输入纯数字'));
  } else {
    callback();
  }
};